
import { TOOL_CATEGORY_CLASS_IDENTIFIER, TOOL_CLASS_IDENTIFIER, TOOL_PROVIDER_CLASS_IDENTIFIER } from '../constants';
import { dsFind, dsFindOne, dsInsert, dsUpdateById, dsUpdateByKeys, ComparsionOperator, dsBatchInsert } from '../local';
import { g01DSFind } from './datasource';


export const rrg01FetchToolList = async () => {
    //合并到本地中
    try {
        //
        let provider = await g01DSFind(TOOL_PROVIDER_CLASS_IDENTIFIER, {});

        try {
            await dsBatchInsert(0, provider.data.map((item) => {
                return [TOOL_PROVIDER_CLASS_IDENTIFIER, item];
            }), {
                upsert: true,
                primary_key: 'identifier'
            });
        } catch (error) {
            console.error(error);
        }
    } catch (error) {
        console.error(error);
    }
    try {
        //
        let provider = await g01DSFind(TOOL_CLASS_IDENTIFIER, {});

        try {
            await dsBatchInsert(0, provider.data.map((item) => {
                return [TOOL_CLASS_IDENTIFIER, item];
            }), {
                upsert: true,
                primary_key: 'identifier'
            });
        } catch (error) {
            console.error(error);
        }
    } catch (error) {
        console.error(error);
    }
    try {
        //
        let provider = await g01DSFind(TOOL_CATEGORY_CLASS_IDENTIFIER, {});

        try {
            await dsBatchInsert(0, provider.data.map((item) => {
                return [TOOL_CATEGORY_CLASS_IDENTIFIER, item];
            }), {
                upsert: true,
                primary_key: 'identifier'
            });
        } catch (error) {
            console.error(error);
        }
    } catch (error) {
        console.error(error);
    }
    return;
}